$(function(){
	var fl6 = $("#miaosha");
	if(fl6.length<1){
		$(".fixed-side").find("li").first("li").hide();
	}else{
		$(".fixed-side").find("li").first("li").show();
	}
	$(".floor-tabbox .list-3").find("li:eq(1)").width("424px");
	$(".pull-box").addClass("open");
	//banner背景
	$(".global-banner .bd li").each(function(){
		var data = $(this).find("img").attr("datacol");
		$(this).css("background-color",data);
	});
	//首页极顶级分类页楼层导航 函数
	$.catetopLift = function(){
	// dom
	var lift = $("*[ectype='lift']");
	var lift_item = lift.find("*[ectype='liftItem']");
	var floor_wp = $("*[ectype='goods_cat_level']");
	var floorItem = floor_wp.find("*[ectype='floorItem']");
	var winWidth = $(window).width();
	var winHeight = $(window).height();
	
	//楼层对应框总个数
	var length = lift_item.length;
	
	//楼层对应框
	var lift_floor_item = "lift-floor-item";
	
	//放回顶部
	var returnTop = "lift-item-top";
	
	//隐藏样式
	var hideClass = "lift-hide";
	
	var left = 0;
	
	
	if(winWidth<1400){
		left = ((winWidth-1200)/2 - lift.width())/2;
	}else{
		left = (winWidth-1200)/2 - lift.width() - 50;
	}
	
	var top = "50%";
	
	lift.css({"left":left,"top":top});
	
	// init
	function init(){
		var bstop = $(window).scrollTop();
		var i = 0;
		var firstItem = "";
		var firstTarget;
		
		//判断首页内容滚动层级首个层级是否存在
		if(lift_item.eq(0).is(":hidden")){
			lift_item.each(function(index, element){
				if($(element).is(":hidden")){
					i++;
				}
			});
		}
		firstItem = lift_item.eq(i);
		
		if(firstItem.hasClass(lift_floor_item)){
			firstTarget = floor_wp;
		}else{
			firstTarget = $(firstItem.attr("data-target"));
		}
		/*if(bstop > firstTarget.offset().top-100){
			if(lift.hasClass(hideClass)){
				lift.removeClass(hideClass);
			}
		}else{
			if(!lift.hasClass(hideClass)){
				lift.addClass(hideClass)
			}
		}*/
		lift_item.each(function(i, el){
			var $el = $(el);
			var $target = $($el.attr("data-target")).eq(0);
			var dom;
			var actClass = "active";
			if($target.length){
				dom = $target;
			}else if($el.hasClass(lift_floor_item)){
				var index = $("." + lift_floor_item).index($el);
				dom = floorItem.eq(index);
			}else{
				return;
			}
			dotop = dom.offset().top - 150;
			if(dotop - 150 > bstop){
				if($el.hasClass(actClass)){
					$el.removeClass(actClass);
				}
			}else{
				if(!$el.hasClass(actClass)){
					$el.addClass(actClass).siblings().removeClass(actClass);
				}
			}
		});
	}
	// scroll
	$(window).scroll(init);
	// click
	$(document).on("click","*[ectype='liftItem']",function(){
		var $this = $(this);
		var target = $this.attr("data-target");
		var $target = $(target).eq(0);
		var oftop;
		
		if($this.hasClass(returnTop)){
			oftop = 0;
		}else if($this.hasClass(lift_floor_item)){
			// 分类楼层
			var index = $("." + lift_floor_item).index($this);
			oftop = floorItem.eq(index).offset().top + 30;
		}else{
			// 其它
			if(!$target.length) return;
			oftop = $target.offset().top;
		}
		$("body,html").stop().animate({scrollTop:oftop-60});
	});
		
	$(window).resize(function(){
		winWidth = $(this).width();
		left = ((winWidth-1200)/2 - lift.width())/2;
		top = "50%";
		
		if(winWidth<1400){
			left = 20;
		}else{
			left = (winWidth-1200)/2 - lift.width() - 50;
		}
		
		lift.css({"left":left,"top":top});
	});
	}
	$.catetopLift();
});
